const { resolve } = require('path')
const { sync } = require('glob')
// 获取所有入口文件
const getEntry = globPath => {
  let entries = {}
  sync(globPath).forEach(entry => {
    const pathname = entry.split('/js/').splice(-1).join('/').split('.')[0]
    entries[pathname] = ['./src/static/js/' + pathname]
  })
  return entries
}
// 根目录
const rootDir = resolve(__dirname, '../')
// src目录
const srcDir = resolve(rootDir, './src')
// 入口文件路径
const entryPath = resolve(rootDir, './src/static/js/**/*.js')
// 入口文件
const entry = getEntry(entryPath)
// 开发环境
const isDevelopment = process.env.NODE_ENV === 'development'
// 排除目录
const exclude = /(node_modules|bower_components)/
module.exports = {
  entry,
  srcDir,
  rootDir,
  exclude,
  isDevelopment
}
